package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.SysCompanyUserControllerApi;
import com.nineclock.system.dto.SysCompanyUserDTO;
import com.nineclock.system.service.SysCompanyUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("companyUser")
@Slf4j
public class SysCompanyUserController implements SysCompanyUserControllerApi {

    @Autowired
    SysCompanyUserService sysCompanyUserService;

    @Override
    @GetMapping("/queryone")
    public Result<SysCompanyUserDTO> findCompanyUserByMobile(String mobile) {
        SysCompanyUserDTO companyUserDTO= sysCompanyUserService.findCompanyUserByMobile(mobile);
        return Result.success(companyUserDTO);
    }

    @Override
    @GetMapping("/query")
    public Result<List<SysCompanyUserDTO>> queryCompanyUser(
            @RequestParam(value = "companyId", required = false) Long companyId,
            @RequestParam(value = "userId", required = false) Long userId) {
        List<SysCompanyUserDTO> sysCompanyUserDTOList=sysCompanyUserService.queryCompanyUser(companyId,userId);
        return Result.success(sysCompanyUserDTOList);
    }
}
